package myIO;

import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;


/*
 * 需求：将键盘录入的数据写到指定的文件中
 * 
 * 
 * 转换流：需要把字节输入流转换成字符输入流。InputStreamReader
 */
public class InputStreamReadrDemo {
	public static void main(String[] args) throws IOException {
		InputStream is = System.in;
		Reader r = new InputStreamReader(is);
		FileWriter fw = new FileWriter("a.txt");
		
		char[] chs = new char[1024];
		int len;
		while((len = r.read(chs)) != -1) {
			fw.write(chs);
			fw.flush();
		}
		//释放资源
		is.close();
		fw.close();
	}
}
